home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 12 - 1996 / 12.12 Dec 96 / Custom AppMaker 2 / CSoundAttachment / CSoundAttachment.cp next >
Encoding:
Text File  |  1996-03-20  |  864 b   |  34 lines  |  [TEXT/BROW]

  1.  
  2. #include     "CSoundAttachment.h"
  3. #include    "USoundPlayer.h"
  4.  
  5. #include    <string.h>
  6.  
  7. // use with an entry in FinishCreateSelf, such as:
  8. //     mOpenFilingButton->AddAttachment(new CSoundAttachment("Click", msg_Click));
  9.  
  10. // ===========================================================================
  11. // • CSoundAttachment                                         CSoundAttachment •
  12. // ===========================================================================
  13. //    Plays sound when executed
  14. //        Suitable for use with any message
  15.  
  16. CSoundAttachment::CSoundAttachment(
  17.     const char*    inSoundName,
  18.     MessageT    inMessage,
  19.     Boolean        inExecuteHost)
  20.         : LAttachment(inMessage, inExecuteHost)
  21. {
  22.     mSoundName[0] = strlen(inSoundName);
  23.     memcpy(&mSoundName[1], inSoundName, mSoundName[0]);
  24. }
  25.  
  26.  
  27. void
  28. CSoundAttachment::ExecuteSelf(
  29.     MessageT    /* inMessage */,
  30.     void*        /* ioParam */)
  31. {
  32.     USoundPlayer::PlaySound(mSoundName);
  33. }
  34.